package cn.edu.ctbu.demo.service;

import cn.edu.ctbu.demo.dao.StudentRepository;
import cn.edu.ctbu.demo.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    public StudentRepository studentRepository;
    public List<Student> getAll() {

        return studentRepository.findAll();

    }

    public Student add(Student student) {
        return studentRepository.save(student);
    }

    public Student gengxin(Student student) {
        return studentRepository.save(student);
    }

    public void shanchu(Integer id) {
        studentRepository.deleteById(id);
    }

}
